package com.he.staticproxymodel.subject.concretecomponent;

import com.he.staticproxymodel.product.BeautifulGirl;
import com.he.staticproxymodel.decorator.concretedecorator.CatGift;
import com.he.staticproxymodel.decorator.concretedecorator.HouseGift;
import com.he.staticproxymodel.decorator.concretedecorator.KindLoveGift;
import com.he.staticproxymodel.subject.GiveGift;
import com.he.staticproxymodel.util.BeautifulLevelEnum;

/**
 * 被代理的realSubject类，也是装饰器模式的具体功能类
 */
public class RichMan implements GiveGift {
    private BeautifulGirl beautifulGirl;
    public GiveGift giveGift;

    public void changeGirl(BeautifulGirl beautifulGirl) {
        this.beautifulGirl = beautifulGirl;
        if (BeautifulLevelEnum.GOOD == this.beautifulGirl.beautifulLevel()) {
            giveGift = new CatGift(this);
        } else if (BeautifulLevelEnum.NICE == this.beautifulGirl.beautifulLevel()) {
            giveGift = new HouseGift(this);
        } else if (BeautifulLevelEnum.PERFECT == this.beautifulGirl.beautifulLevel()) {
            GiveGift giveGift = new CatGift(this);
            HouseGift houseGift = new HouseGift(giveGift);
            this.giveGift = new KindLoveGift(houseGift);
        } else {
            throw new AssertionError("请传入美丽的girl！");
        }
    }

    @Override
    public void giveGift() {
        System.out.println("的礼物！");
    }
}
